package com.project.controller;

import com.project.bean.SpeakBean;
import com.project.bean.UserBean;
import com.project.service.ISpeakService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("speak")
public class SpeakController {

    @Autowired
    private ISpeakService service;

    @RequestMapping("add")
    public String add(int bookId, String content, HttpServletRequest req){
        UserBean user = (UserBean) req.getSession().getAttribute("loginUser");
        SpeakBean speak = new SpeakBean(bookId,user.getId(),content);
        service.add(speak);
        return "ok";

    }
}
